﻿namespace BM.Tools.WebControls.MForm
{
    using System;
    using BM.Tools.WebControls.MForm.Controls;

    /// <summary>
    /// An exception that is thrown when some functionality is used for an offspring type that it was not designed to be used with.
    /// </summary>
    public class InvalidOffspringTypeException : Exception
    {
        /// <summary>
        /// Initializes a new instance of the <see cref="InvalidOffspringTypeException"/> class. 
        /// </summary>
        /// <param name="validType">
        /// The valid type.
        /// </param>
        public InvalidOffspringTypeException(OffspringType validType)
        {
            ValidType = validType;
        }

        /// <summary>
        /// Initializes a new instance of the <see cref="InvalidOffspringTypeException"/> class. 
        /// </summary>
        /// <param name="validType">
        /// The valid type.
        /// </param>
        /// <param name="innerException">
        /// The inner exception.
        /// </param>
        public InvalidOffspringTypeException(OffspringType validType, Exception innerException)
            : base(null, innerException)
        {
            ValidType = validType;
        }

        /// <summary>
        /// Gets ValidType.
        /// </summary>
        /// <value>
        /// The valid type that would not throw the exception.
        /// </value>
        public OffspringType ValidType
        {
            get; 
            private set;
        }

        /// <summary>
        /// Gets Message.
        /// </summary>
        /// <value>
        /// The message.
        /// </value>
        public override string Message
        {
            get
            {
                return "The only type that can be used for this functionality is " + ValidType;
            }
        }
    }
}